/**
 * techforce-blog-full-screan
 * @name techforce-blog-full-screan
 * @author zhuyuchao - http://ioteam.zjgsu.edu.cn/blog
 * @version 0.1
 */
var view_frame = document.getElementsByTagName("iframe")[0];
//save default height&width of the frame
var view_frame_width = 584;
view_frame.width = view_frame_width;
var view_frame_height = 700;
view_frame.height = view_frame_height;

//create the div with the button of show 
var show_button_div = document.createElement("div");
show_button_div.innerHTML = "<a href='javascript:show()' style='display:block; background-color: #357AE8; color:#ffffff;font:bold 13px/23px arial,sans-serif; height:23px; width:100px; text-decoration:none; text-align:center; border:solid 1px #eeeeee; padding-top:3px;margin:5px;'>全屏显示</a>";
view_frame.parentNode.insertBefore(show_button_div,view_frame);

//create the div for view 
var view_div =  document.createElement("div");
//view_div.setAttribute("id","view_div");
view_frame.parentNode.insertBefore(view_div,view_frame);
view_div.appendChild(view_frame);

function show(){
  document.body.style.overflowY = "hidden";
	//add the css to the div of view
  var view_div_css_text = "position:fixed;top:0;left:0;width:100%;padding:0;background-color:#ffffff;z-index:100000;";
	view_div.style.cssText = view_div_css_text;
	
	//create the div for close
	var close_div = document.createElement("div");
	close_div.setAttribute("id","close_div");
  var close_div_css_text = "display: block;width: 100%;padding: 7px;margin: 0px;background-color:#ffffff;z-index:100001";
	close_div.style.cssText = close_div_css_text;
  close_div.innerHTML = "<a href='javascript:closed()' style='display:block; background-color:#357AE8 ; color:#ffffff;font:bold 12px/23px arial,sans-serif; height:22px; width:100px; text-decoration:none; text-align:center; border:solid 1px #eeeeee;'>关闭全屏显示</a>";
	
	//add the close div to div 0f view
	view_div.insertBefore(close_div,view_frame);
	
	//change size of frame and view
	changeSize();
}

function closed(){
	var close_div = document.getElementById("close_div");
	view_div.removeChild(close_div);
	view_div.style.cssText = null;
	view_frame.height = view_frame_height;
	view_frame.width = view_frame_width;
  view_div.style.height = view_frame_height;
	document.body.style.overflowY = "auto";
}

function changeSize(){
    var winHeight;
    var close_height = document.getElementById("close_div").offsetHeight;
    
    if (window.innerHeight) 
        winHeight = window.innerHeight;
    else 
        if ((document.body) && (document.body.clientHeight)) 
            winHeight = document.body.clientHeight;
    
    if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
        winHeight = document.documentElement.clientHeight;
    }
    
    view_div.style.height = winHeight + "px";
    view_frame.height = winHeight - close_height + "px";
	view_frame.width = "100%";
}

window.onresize = function(){
    if(document.getElementById("fullhead_div")!=null){
		changeSize();
	}
}
